Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

credential-cache: handle ECONNREFUSED gracefully #5329

Merged
merged 4 commits into from
Jan 1, 2025

Conversation

rimrul
Copy link
Member

@rimrul rimrul commented Dec 22, 2024

I should probably add some tests for this.

@rimrul rimrul linked an issue Dec 22, 2024 that may be closed by this pull request
1 task
@rimrul rimrul force-pushed the credential-cache-unknown-error branch 2 times, most recently from ff41d09 to 1059d6f Compare December 22, 2024 18:47
Copy link

@hickford hickford Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To distinguish the two identical error messages "unable to connect to cache daemon", consider changing the second to “unable to connect to spawned cache daemon”

@rimrul rimrul force-pushed the credential-cache-unknown-error branch 5 times, most recently from de3a367 to 42da5df Compare December 29, 2024 11:08
@rimrul rimrul marked this pull request as ready for review December 29, 2024 11:10
@rimrul
Copy link
Member Author

rimrul commented Dec 29, 2024

Turns out, the existing tests would've caught this issue, if I hadn't unintentionally sabotaged them

@hickford
Copy link

hickford commented Jan 1, 2025

@dscho Might this be fixed in 2.48 or will it have to wait for 2.49?

@dscho
Copy link
Member

dscho commented Jan 1, 2025

@dscho Might this be fixed in 2.48 or will it have to wait for 2.49?

Thanks for reminding me; I had meant to include this in -rc1 but got overwhelmed with the amount of work required to rebase Git for Windows from -rc0 to -rc1 and have it build and pass the tests ☹️

@dscho dscho force-pushed the credential-cache-unknown-error branch from 42da5df to 7db4028 Compare January 1, 2025 16:19
@dscho
Copy link
Member

dscho commented Jan 1, 2025

Range-diff after I rebased onto -rc1
  • 1: 2dbebb9 ! 1: bb32934 compat/mingw: handle WSA errors in strerror

    @@ Commit message
     
         Reported-by: M Hickford <[email protected]>
         Signed-off-by: Matthias Aßhauer <[email protected]>
    +    Signed-off-by: Johannes Schindelin <[email protected]>
     
      ## Makefile ##
     @@ Makefile: THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/%
      
    - CLAR_TEST_SUITES += ctype
    - CLAR_TEST_SUITES += strvec
    -+CLAR_TEST_SUITES += mingw
    + CLAR_TEST_SUITES += u-ctype
    + CLAR_TEST_SUITES += u-strvec
    ++CLAR_TEST_SUITES += u-mingw
      CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X)
      CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
      CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
    @@ compat/mingw.h: int mingw_socket(int domain, int type, int protocol);
      #define bind mingw_bind
      
     
    - ## t/unit-tests/mingw.c (new) ##
    + ## t/unit-tests/u-mingw.c (new) ##
     @@
     +#include "unit-test.h"
     +
  • 2: 7ed7a8f ! 2: d2b552f compat/mingw: drop outdated comment

    @@ Commit message
         about these errors is untrue since the previous commit.
     
         Signed-off-by: Matthias Aßhauer <[email protected]>
    +    Signed-off-by: Johannes Schindelin <[email protected]>
     
      ## compat/mingw.c ##
     @@ compat/mingw.c: int mingw_socket(int domain, int type, int protocol)
  • 3: 94d288f ! 3: 71aa44f t0301: actually test credential-cache on Windows

    @@ Commit message
         t0301: actually test credential-cache on Windows
     
         Commit 2406bf5 (Win32: detect unix socket support at runtime,
    -    2024-04-03) introduced a runtime detection for wether the operating
    +    2024-04-03) introduced a runtime detection for whether the operating
         system supports unix sockets for Windows, but a mistake snuck into the
         tests. When building and testing Git without NO_UNIX_SOCKETS we
         currently skip t0301-credential-cache on Windows if unix sockets are
    @@ Commit message
         Flip that logic to actually work the way it was intended.
     
         Signed-off-by: Matthias Aßhauer <[email protected]>
    +    Signed-off-by: Johannes Schindelin <[email protected]>
     
      ## t/t0301-credential-cache.sh ##
     @@ t/t0301-credential-cache.sh: test -z "$NO_UNIX_SOCKETS" || {
  • 4: 42da5df ! 4: 7db4028 credential-cache: handle ECONNREFUSED gracefully

    @@ Commit message
     
         Helped-by: M Hickford <[email protected]>
         Signed-off-by: Matthias Aßhauer <[email protected]>
    +    Signed-off-by: Johannes Schindelin <[email protected]>
     
      ## builtin/credential-cache.c ##
     @@ builtin/credential-cache.c: static int connection_closed(int error)

rimrul added 4 commits January 1, 2025 17:27
We map WSAGetLastError() errors to errno errors in winsock_error_to_errno(),
but the MSVC strerror() implementation only produces "Unknown error" for
most of them. Produce some more meaningful error messages in these
cases.

Our builds for ARM64 link against the newer UCRT strerror() that does know
these errors, so we won't change the strerror() used there.

The wording of the messages is copied from glibc strerror() messages.

Reported-by: M Hickford <[email protected]>
Signed-off-by: Matthias Aßhauer <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
The part about keeping the original error number hasn't been accurate since
commit c11f75c (mingw: make sure errno is set correctly when socket
operations fail, 2019-11-25) and the part about strerror() not knowing
about these errors is untrue since the previous commit.

Signed-off-by: Matthias Aßhauer <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
Commit 2406bf5 (Win32: detect unix socket support at runtime,
2024-04-03) introduced a runtime detection for whether the operating
system supports unix sockets for Windows, but a mistake snuck into the
tests. When building and testing Git without NO_UNIX_SOCKETS we
currently skip t0301-credential-cache on Windows if unix sockets are
supported and run the tests if they aren't.

Flip that logic to actually work the way it was intended.

Signed-off-by: Matthias Aßhauer <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
In 245670c (credential-cache: check for windows specific errors, 2021-09-14)
we concluded that on Windows we would always encounter ENETDOWN where we
would expect ECONNREFUSED on POSIX systems, when connecting to unix sockets.
As reported in [1], we do encounter ECONNREFUSED on Windows if the
socket file doesn't exist, but the containing directory does and ENETDOWN if
neither exists. We should handle this case like we do on non-windows systems.

[1] git-for-windows#4762 (comment)

This fixes git-for-windows#5314

Helped-by: M Hickford <[email protected]>
Signed-off-by: Matthias Aßhauer <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho force-pushed the credential-cache-unknown-error branch from 7db4028 to 9a70050 Compare January 1, 2025 16:27
@dscho
Copy link
Member

dscho commented Jan 1, 2025

Oops
  • 1: bb32934 ! 1: e71f228 compat/mingw: handle WSA errors in strerror

    @@ compat/mingw.h: int mingw_socket(int domain, int type, int protocol);
      #define bind mingw_bind
      
     
    + ## t/meson.build ##
    +@@
    + clar_test_suites = [
    +   'unit-tests/u-ctype.c',
    ++  'unit-tests/u-mingw.c',
    +   'unit-tests/u-strvec.c',
    + ]
    + 
    +
      ## t/unit-tests/u-mingw.c (new) ##
     @@
     +#include "unit-test.h"
  • 2: d2b552f = 2: 86c5a9b compat/mingw: drop outdated comment

  • 3: 71aa44f = 3: dfbc6bd t0301: actually test credential-cache on Windows

  • 4: 7db4028 = 4: 9a70050 credential-cache: handle ECONNREFUSED gracefully

@dscho dscho merged commit 58d6792 into git-for-windows:main Jan 1, 2025
49 checks passed
@dscho dscho added this to the Next release milestone Jan 1, 2025
@dscho
Copy link
Member

dscho commented Jan 1, 2025

/add relnote bug When using the cache credential helper, it could error out with "fatal: unable to connect to cache daemon: Unknown error" under certain circumstances; This was fixed.

The workflow run was started

github-actions bot pushed a commit to git-for-windows/build-extra that referenced this pull request Jan 1, 2025
When using the `cache` credential helper, it could error out with
"fatal: unable to connect to cache daemon: Unknown error" under certain
circumstances; This [was
fixed](git-for-windows/git#5329).

Signed-off-by: gitforwindowshelper[bot] <[email protected]>
git-for-windows-ci pushed a commit that referenced this pull request Jan 1, 2025
I should probably add some tests for this.
git-for-windows-ci pushed a commit that referenced this pull request Jan 1, 2025
I should probably add some tests for this.
@rimrul rimrul deleted the credential-cache-unknown-error branch January 1, 2025 21:58
git-for-windows-ci pushed a commit that referenced this pull request Jan 1, 2025
I should probably add some tests for this.
git-for-windows-ci pushed a commit that referenced this pull request Jan 1, 2025
I should probably add some tests for this.
git-for-windows-ci pushed a commit that referenced this pull request Jan 1, 2025
I should probably add some tests for this.
git-for-windows-ci pushed a commit that referenced this pull request Jan 2, 2025
I should probably add some tests for this.
git-for-windows-ci pushed a commit that referenced this pull request Jan 2, 2025
I should probably add some tests for this.
git-for-windows-ci pushed a commit that referenced this pull request Jan 2, 2025
I should probably add some tests for this.
git-for-windows-ci pushed a commit that referenced this pull request Jan 3, 2025
I should probably add some tests for this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

credential-cache error "fatal: unable to connect to cache daemon: Unknown error"
3 participants